package org.jeecg.config;

import org.jeecg.access.service.UnifiedPlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @description: todo
 * @author: taogang
 * @date: 2025/7/29 16:28
 */
@Component
public class PlatformServiceRegistry {
    private final Map<String, UnifiedPlatformService> serviceMap = new ConcurrentHashMap<>();

    @Autowired
    public PlatformServiceRegistry(List<UnifiedPlatformService> services) {
        for (UnifiedPlatformService service : services) {
            serviceMap.put(service.getPlatformTypeCode(), service);
        }
    }

    public UnifiedPlatformService getService(String platformType) {
        return serviceMap.get(platformType);
    }

    public List<UnifiedPlatformService> getAllServices() {
        return new ArrayList<>(serviceMap.values());
    }
}
